Skip to content

Add --cabal-file-{sha256,revision} arguments#715

Closed
9999years wants to merge 1 commit intoNixOS:masterfrom
9999years:wiggles/ppqx
Closed

Add --cabal-file-{sha256,revision} arguments#715
9999years wants to merge 1 commit intoNixOS:masterfrom
9999years:wiggles/ppqx

Conversation

@9999years
Copy link
Copy Markdown
Contributor

This lets cabal2nix generate derivations with editedCabalFile and revision fields. This functionality already exists in hackage2nix but wasn't exposed in cabal2nix.

This lets `cabal2nix` generate derivations with `editedCabalFile` and
`revision` fields. This functionality already exists in `hackage2nix`
but wasn't exposed in `cabal2nix`.
@sternenseemann
Copy link
Copy Markdown
Member

This functionality is exposed in cabal2nix, but only in certain situations:

  • When using the cabal-install database, it will correctly be generated based on the current DB state, e.g. cabal2nix cabal://socket-0.8.3.0.
  • If the cabal file has a x-revision field (like Hackage would have), cabal2nix will also generate the arguments, though I would need to check whether the editedCabalFileSha256 is actually correct in that case. See also cabal2nix tries to fetch hackage revisions even if already present in the source #550. I'm not sure what the best sort of behavior is in that situation, realistically, I think, cabal files not downloaded from Hackage shouldn't have x-revision set.

Maybe you could elaborate why these extra flags are interesting to you? I think revision are a little bit tricky. Ideally, we would just have cabal2nix do the right thing when necessary and otherwise hide this detail from the user as much as possible. (Arguably the mechanism is a layer violation to begin with which is probably why dealing with it is so annoying…)

@9999years
Copy link
Copy Markdown
Contributor Author

If the cabal file has a x-revision field (like Hackage would have), cabal2nix will also generate the arguments

Ah, that might be it; I think I tested this with revision 0 of a .cabal file.

For some more context, this is related to the "vendor-cabal2nix" project which we intend to use to pin various Haskell dependencies in an ergonomic fashion without incurring IFD costs.

@9999years
Copy link
Copy Markdown
Contributor Author

Yes, that works! Thanks for the reminder. I can close this, apologies for the ping.

curl -O https://hackage.haskell.org/package/aeson-diff-1.1.0.13/revision/1.cabal
cabal2nix --sha256 8b0d0b9dd58675124d85c9285dce7028c4c9246b46ba5eaad2610269011ea169 1.cabal
{ mkDerivation, aeson, base, bytestring, Cabal, cabal-doctest
, directory, doctest, edit-distance-vector, filepath, Glob, lib
, optparse-applicative, QuickCheck, scientific, text, vector, yaml
}:
mkDerivation {
  pname = "aeson-diff";
  version = "1.1.0.13";
  sha256 = "8b0d0b9dd58675124d85c9285dce7028c4c9246b46ba5eaad2610269011ea169";
  revision = "1";
  editedCabalFile = "1028adallw7bm72948lj322bb5a99gfs0qc1j0pnm8hryp6n7ma5";
  isLibrary = true;
  isExecutable = true;
  setupHaskellDepends = [ base Cabal cabal-doctest ];
  libraryHaskellDepends = [
    aeson base bytestring edit-distance-vector scientific text vector
  ];
  executableHaskellDepends = [
    aeson base bytestring optparse-applicative yaml
  ];
  testHaskellDepends = [
    aeson base bytestring directory doctest filepath Glob QuickCheck
    vector
  ];
  homepage = "https://github.com/ysangkok/aeson-diff";
  description = "Extract and apply patches to JSON documents";
  license = lib.licenses.bsd3;
}

@9999years 9999years closed this Apr 2, 2026
@9999years 9999years deleted the wiggles/ppqx branch April 2, 2026 16:51
@sternenseemann
Copy link
Copy Markdown
Member

Is the editedCabalFile sha256 actually correct, did you check?

@9999years
Copy link
Copy Markdown
Contributor Author

Looks good:

$ curl -O https://hackage.haskell.org/package/aeson-diff-1.1.0.13/revision/1.cabal
$ sha256sum 1.cabal
45d563cdf519a26a2f908161a0dd4b4995b58418922292c4a9eb704a55534880  1.cabal
$ nix-hash --to-base16 --type sha256 1028adallw7bm72948lj322bb5a99gfs0qc1j0pnm8hryp6n7ma5
45d563cdf519a26a2f908161a0dd4b4995b58418922292c4a9eb704a55534880

@sternenseemann
Copy link
Copy Markdown
Member

Thanks for checking, great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants